home *** CD-ROM | disk | FTP | other *** search
- int wordcount(char *str)
- {
- int count = 0;
- char *s;
- s=str;
- while(*s && *s==' ')
- s++; //Skip leading spaces
- while(s)
- {
- s=strchr(s,' '); //Find the first word break
- while(*s && *s==' ')
- s++; //Allow for multiple spaces
- count++; //Increment count - Note it starts as 0 not 1
- }
- return(count);
- }
-
-
-